//
//  NetworkAPI.h
//  ACE
//
//  Created by Mickey Yin on 2021/12/4.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

//声明了一个下载成功的block类型
typedef void (^ifaaMsgToServerSuccess) (BOOL success, NSString *data);
//声明一个失败的block类型
typedef void (^ifaaMsgToServerError) (NSError *error);

typedef void(^HttpSuccess)(id _Nonnull json);
typedef void(^HttpFailure)(NSError* _Nonnull error);

@interface NetworkAPI : NSObject

@property (nonatomic, copy) ifaaMsgToServerSuccess successBlock;
@property (nonatomic, copy) ifaaMsgToServerError errorBlock;
@property (nonatomic, copy) NSURL *nsURL;

/**
 GET请求 不带 header
 
 @param url 请求的URL
 @param params 请求的参数
 @param success 成功回调
 @param failure 失败回调
 */
+(void)getWithURLString:(NSString *)url params:(NSDictionary *_Nonnull)params success:(HttpSuccess)success failure:(HttpFailure)failure;

/**
 POST请求 不带 header
 
 @param url 请求的URL
 @param params 请求的参数
 @param success 成功回调
 @param failure 失败回调
 */
+(void)postWithURLString:(NSString *)url params:(NSDictionary *_Nonnull)params success:(HttpSuccess)success failure:(HttpFailure)failure;

/**
 POST请求 带 header
 
 @param url 请求的URL
 @param params 请求的参数
 @param header 请求头
 @param success 成功回调
 @param failure 失败回调
 */
+(void)postHeaderWithURLString:(NSString *)url params:(NSDictionary *_Nonnull)params header:(NSDictionary *)header success:(HttpSuccess)success failure:(HttpFailure)failure;



@end

NS_ASSUME_NONNULL_END
